<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;

class createSettingsTable extends Migration
{
    public function up()
    {
        Schema::create('settings', function (Blueprint $table) {
            $table->increments('id');

            $table->string('name')->comment('用于系统调用');
            $table->unsignedInteger('order')->default(0)->comment('排序');
            $table->unsignedInteger('group_id')->default(0)->comment('分组ID');
            $table->string('display_name')->comment('用于后台显示');
            $table->string('value_type')->default('string')->comment('值的类型');
            $table->string('form_type')->default('text')->comment('表单的类型');
            $table->text('form_optional')->comment('form的可选值，在form_type为radio、checkbox、select的时候需要填写');
            $table->text('value')->comment('值');

            $table->index('group_id');
            $table->unique('name');
        });
    }

    public function down()
    {
        Schema::dropIfExists('settings');
    }
}
